<template>
  <transition name="fade">
    <h1 v-if="show">你好 Vue3!</h1>
  </transition>

  <button @click="toggle">点击</button>
</template>

<script setup>
  import {ref} from 'vue'
  let show = ref(true)
  function toggle() {
    show.value = !show.value
  }
</script>

<style scoped>
  .fade-enter-active,.fade-leave-active {
    transition: opacity 0.5s linear;
  }
  .fade-enter-from,.fade-leave-to {
    opacity: 0;
  }
</style>
